Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send current state of the subscriptions #444

Merged

Conversation

crodas
Copy link
Contributor

@crodas crodas commented Nov 8, 2024

Improve #394

Make WebSocket subscriptions send the current status when subscribing. It would also be interesting to implement this logic into the PubSub crate. If we do this, this solution would be agnostic to the WebSocket, and any other bit of the rust code that wants to subscribe would inherit messages of current status when they subscribe. What are your thoughts @thesimplekid ?

@crodas crodas force-pushed the web-socket-subscription-current-status branch from 3862819 to 5a199bb Compare November 8, 2024 12:57
@thesimplekid
Copy link
Collaborator

It would also be interesting to implement this logic into the PubSub crate

It looks like the pubsub mod doesn't currently have access to the database so we would have to provide that? I'm happy with it in either place so if you think its worth refactoring to put it there I'm happy with that, I do see your point about making it agnostic, but if its much more complicated it may not be worht it?

Looking at the current code it looks good my only concern is it looks like we will silently fail, granted on calls that really shouldnt fail, but in general I think its good to at least log errors if returning them is impractical as we don't want to stop the whole call failing for a partial failure.

@crodas crodas force-pushed the web-socket-subscription-current-status branch 5 times, most recently from 51a679b to 43af4a0 Compare November 9, 2024 14:47
@crodas crodas marked this pull request as ready for review November 9, 2024 16:15
@@ -9,6 +13,20 @@ use crate::{
};
use serde::{Deserialize, Serialize};
use std::ops::Deref;
#[cfg(feature = "mint")]
use std::sync::Arc;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you reorder these imports to be consistent with the style guide.

https://github.com/cashubtc/cdk/blob/main/CODE_STYLE.md#order-of-imports

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it better now @thesimplekid ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#449

fixed it here no need to hold up merging for that

crates/cdk/src/nuts/nut17/on_subscription_no_op.rs Outdated Show resolved Hide resolved
@thesimplekid
Copy link
Collaborator

Rebase on main will fix the ci issue

I moved the logic to send the initial values to the subscriptions onto a
generic trait implemented in nut17. The main goal is to have the same behavior
regardless of whether the subscriptions come from web sockets or internally
from other parts of the systems or other crates.
Add a no-op code handle for subscription creation when the crate is compiled
without the mint feature
@crodas crodas force-pushed the web-socket-subscription-current-status branch from 43af4a0 to 2c7cb80 Compare November 9, 2024 22:43
@crodas crodas requested a review from thesimplekid November 9, 2024 23:15
@thesimplekid thesimplekid merged commit cc5b267 into cashubtc:main Nov 10, 2024
43 checks passed
vnprc pushed a commit to vnprc/cdk that referenced this pull request Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants